@echo off

setlocal

call "%%SVNCMD_TOOLS_ROOT%%/make_url_absolute.bat" "%%BASE_URL%%" "%%TRANSFORM_PATH%%" "%%REPO_URL%%"
set ERRORLEVEL_RETURNED=%ERRORLEVEL%
set "URL_RETURNED=%RETURN_VALUE%"

if %TESTLIB__OVERALL_TESTS% GTR %TESTLIB__CURRENT_TESTS% (
  set "TEST_REPORT_PREFIX_STR=%TESTLIB__OVERALL_TESTS%`%TESTLIB__CURRENT_TESTS%"
) else set "TEST_REPORT_PREFIX_STR=%TESTLIB__CURRENT_TESTS%"

if %ERRORLEVEL_RETURNED% NEQ 0 (
  "%CONTOOLS_UTILITIES_ROOT%/bin/envvarcmp.exe" URL_RETURNED STRING_REFERENCE "" ^
    "FAILED: %TEST_REPORT_PREFIX_STR%: (%ERRORLEVEL_RETURNED%) RESULT=`{0}` REFERENCE=`{1}` BASE_URL=`${BASE_URL}` TRANSFORM_PATH=`${TRANSFORM_PATH}` REPO_URL=`${REPO_URL}`" ^
    "FAILED: %TEST_REPORT_PREFIX_STR%: (%ERRORLEVEL_RETURNED%) RESULT=`{0}` REFERENCE=`{1}` BASE_URL=`${BASE_URL}` TRANSFORM_PATH=`${TRANSFORM_PATH}` REPO_URL=`${REPO_URL}` (`{0hs}` != `{1hs}`)"
  echo.
  exit /b 1
)

"%CONTOOLS_UTILITIES_ROOT%/bin/envvarcmp.exe" URL_RETURNED STRING_REFERENCE "" ^
  "PASSED: %TEST_REPORT_PREFIX_STR%: REFERENCE=`{1}` BASE_URL=`${BASE_URL}` TRANSFORM_PATH=`${TRANSFORM_PATH}` REPO_URL=`${REPO_URL}`" ^
  "FAILED: %TEST_REPORT_PREFIX_STR%: RESULT=`{0}` REFERENCE=`{1}` BASE_URL=`${BASE_URL}` TRANSFORM_PATH=`${TRANSFORM_PATH}` REPO_URL=`${REPO_URL}` (`{0hs}` != `{1hs}`)"
if %ERRORLEVEL% NEQ 0 (
  echo.
  exit /b 2
)

exit /b 0
